package mio.model;

import java.util.ArrayList;

public class Path {
	
	private Stop from;
	private ArrayList<Stop> to;
	private ArrayList<Line> lines;
	private ArrayList<Stop> stops;
	private ArrayList<LineChange> changes;
	private ArrayList<Object> steps;
	
	public Path(Stop from, ArrayList<Stop> to){
		this.from = from;
		this.to = to;
		this.lines = new ArrayList<Line>();
		this.stops = new ArrayList<Stop>();
		this.changes = new ArrayList<LineChange>();
		this.steps = new ArrayList<Object>();
	}
	
	public void initPath(Stop in, Line initialLine){
		stops.add(in);
		lines.add(initialLine);
		steps.add("Vaya hacia la parada " + in + " y aborde la linea " + initialLine);
	}
	
	public void changeLine(Stop in, Line from, Line to){
		stops.add(in);
		lines.add(to);
		
		LineChange lc = new LineChange(in, from, to);
		changes.add(lc);
		steps.add(lc);
	}
	
	public String toString(){
		StringBuilder sb = new StringBuilder();
		
		sb.append("Ruta");
		sb.append(" " + from);
		sb.append(" - " + (to.size() == 1 ? to.get(0) : to) + "\n");
		
		for(Object temp : steps)
			sb.append("\t" + temp + "\n");
		
		return sb.toString();
	}
	
	public boolean equals(Object obj){
		if(!(obj instanceof Path))
			return false;
		
		Path other = (Path) obj;
		return steps.equals(other.getSteps());
	}

	public Stop getFrom() {
		return from;
	}

	public ArrayList<Stop> getTo() {
		return to;
	}

	public ArrayList<Line> getLines() {
		return lines;
	}
	
	public ArrayList<Stop> getStops() {
		return stops;
	}
	
	public ArrayList<LineChange> getChanges() {
		return changes;
	}

	public ArrayList<Object> getSteps() {
		return steps;
	}
}
